package com.bean;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.listener.DownloadListener;
import com.listener.ProgressListener;
import com.util.DBUtil;
import com.util.FileDownLoad;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * @author Smile
 */

@Data
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE)
public class DossierFileCatalog {
    private String NodeNo;

    private String NodeParentNo;

    private String JZBH;

    private String MLBH;

    private String WJXH;

    private String SFSC;

    private String DWBM;

    private String BMSAH;

    private String WJLJ;

    private String WJMC;

    private String WJXSMC;

    private String WJHZ;

    private String WJKSY;

    private String WJJSY;

    private String WJBZXX;

    private String WJYZBZ;

    private String WJSXH;

    private String WJZDY;

    private String SSLBBM;

    private String SSLBMC;

    private String WJBM;

    private String PDF;

    private Map<Integer, String> IMG;

    private String TEXT;

    private String NodeName;

    public boolean download(DBUtil dbUtil, DownloadListener listener) throws Exception {
        DownloadListener.Download download = new DownloadListener.Download();
        download.setSuccess(true);
        download.setID(this.getNodeNo());
        try {
            List<SQLiteArgument> sqLiteArguments = FileDownLoad.downLoadDossierFile(this);
//        WebSocket.sendInfo(socketID, this.getWJXSMC() + "下载完成...");
            if (listener != null) {
                listener.download(download);
            }
            return dbUtil.executeUpdate(sqLiteArguments);
        } catch (Exception e) {
            if (listener != null) {
                download.setSuccess(false);
                download.setMessage(e.getMessage());
                listener.download(download);
            }
            throw e;
        }
    }
}
